import React, { Component, PropTypes } from 'react';
import DataTable from '../../DataTable'

class Resources extends Component {

  constructor () {
    super()
    this.state = {
      tableConfig: {
        columns: [{
          title: '资源名称',
          name: 'operationName'
        }, {
          title: '资源代码',
          name: 'operationCode'
        }, {
          title: '父节点',
          name: 'parentId',
          type: 'select',
          data: '/api/resources/tree?resourcesType=ALL'
        }, {
          title: '锚点',
          name: 'operationUrl'
        }, {
          title: '排序',
          name: 'operationSeq'
        }, {
          title: '类型',
          name: 'operationType',
          type: 'select',
          data: '/api/dictionaries/findByTypeCode?dicCode=ResourcesType'
        }, {
          title: '图标',
          name: 'bk2'
        }, {
          title: '启用',
          name: 'isDisabled',
          type: 'boolean'
        }, {
          command: [{
            name: 'create'
          }, {
            name: 'edit',
            text: '编辑'
          }, {
            name: 'delete',
            text: '删除'
          }]
        }],
        transport: {
          read: {
            url: '/api/resources/getPagination',
            parse: () => {}
          },
          create: '/api/resources/add',
          update: {
            url: '/api/resources/edit',
            format: () => {}
          },
          destroy: '/api/resources/del'
        }
      }
    }
  }

  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  }

  render() {
    this.context.onSetTitle('资源管理')
    return (
      <div>
        <DataTable config={this.state.tableConfig} />
      </div>
    )
  }

}

export default Resources;

